/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.asseco.mio.search;

import com.asseco.persistence.service.HibernateUtil;
import org.appfuse.model.User;
import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;

/**
 *
 * @author konstantin.sivakov
 */
public class UserSearch {

    public static User getUserByUserName(String username) {

        User user = new User();
        Session session = HibernateUtil.getSessionFactory().openSession();
        session.beginTransaction();
        
         Criteria criteria = session.createCriteria(User.class).add(Restrictions.eq("username", username));
         
         user = (User) criteria.list().get(0);

        return user;
    }
}
